﻿using System.Collections.Generic;
using Entities.DataBase;
using Entities.DataBase.Obj;

namespace WebService.Service {

    public class UserServiceX : AbstractService, IUserServiceX {
        
        public List<UserInfo> ListUsers(string passport) {
            return Run(passport, token => Services.Locate<IUserRepository>().ListInfos());
        }

        public UserInfo GetUserInfo(string passport, string userId) {
            return Run(passport, token => {
                var user = Locate<IUserRepository>().Get(userId);
                return new UserInfo {
                    UserId = user.UserId,
                    CName  = user.FullName,
                    Name   = user.FullName,
                    Email  = user.Email,
                    Role   = user.UserRole
                };
            });
        }

    }
}
